<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>指标管理</title>

	<link href="<%=path%>/resources/css/new_version/bootstrap.min.css" rel="stylesheet">
	<link href="<%=path%>/resources/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="<%=path%>/resources/css/new_version/site.css" rel="stylesheet">
<link href="<%=path %>/resources/validform/css/style.css" rel="stylesheet">
<link href="<%=path %>/resources/css/dashboard.css" rel="stylesheet">
<link href="<%=path %>/resources/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<link href="<%=path %>/resources/css/bootstrap-select.css" rel="stylesheet">
<!-- Bootstrap core JavaScript
    ================================================== -->
   <script src="<%=path%>/resources/js/new_version/jquery.min.js"></script>
    <script src="<%=path%>/resources/js/new_version/bootstrap.min.js"></script>
    
     <script src="<%=path%>/resources/js/new_version/site.js"></script>
	<script src="<%=path %>/resources/js/bootstrap3.3.5/bootstrap-datetimepicker.js"></script>
	<script src="<%=path %>/resources/js/bootstrap3.3.5/bootstrap-datetimepicker.zh-CN.js"></script>	
	<script type="text/javascript" src="<%=path %>/resources/validform/js/Validform_v5.3.2_min.js"></script>
	<script type="text/javascript" src="<%=path %>/resources/js/bootstrap3.3.5/bootstrap-select.js"></script>
	<script type="text/javascript" src="<%=path %>/resources/js/jquery-ui-min-1.9.js"></script>
	<script type="text/javascript" src="<%=path %>/resources/js/Chinese-characters-to-Pinyin/py.js"></script>
	 <script src="<%=path%>/resources/js/new_version/script.js"></script></head>
  </head>
	<script type="text/javascript">

		function searchInput() {
		var menu_name = $("#countryName1").val();
		var menu_id=$("#number1").val();
		window.location.href = "<%=path%>/ZhibiaoDict/zhibiaoDict?menu_name="+encodeURI(encodeURI(menu_name))+"&menu_id="+menu_id;
			//$("#form1").submit();
		}
 	 document.onkeydown=function(event){
		    var e = event || window.event || arguments.callee.caller.arguments[0];         
		    if(e && e.keyCode==13){ // enter 键
		    	searchInput();
		    }
		} 
	</script>
  <body style="margin:0; padding:0">

<%-- <h2 class="content_title">${title}</h2> --%>
	<div  class="content_waikuang">
	   <div class="container-fluid search_select " style="margin-right:50px">
	   <h2 class="content_title">指标字典管理</h2>
   		<div  class="renwu_caozuo">
   		     <a  class="renwu_select" style="text-decoration:none" href="#" data-toggle="modal" id="add_0" data-target="#editDemand" onclick="OpenAddModel()">指标添加</a>
   		</div>
     </div>
     <div class="row" style="clear: both">
     			<form action="<%=path%>/ZhibiaoDict/zhibiaoDict" id="pageform">
				<div class="span3 " style="width: 17%">
					<div class="well content_left">
						<h4>筛选器</h4>
						<dl class="nav nav-list nav_headerxs" id="select1">
							<dt class="nav-header">搜索</dt>
							<dd class="nav_leftinput" style="display: block">
								<input id="countryName1" name="countryName1" value=""
									placeholder="指标名称" type="text" style="width: 94%"> <img
									src="/xxsc/resources/img/new_version/search1.png"
									onclick="searchInput()" />
							</dd>
							<dd class="nav_leftinput" style="display: block">
								<input id="number1" name="number1" value=""
									placeholder="指标编码" type="text" style="width: 94%"> <img
									src="/xxsc/resources/img/new_version/search1.png"
									onclick="searchInput()" />
							</dd>
						</dl>
					</div>					
				</div>
				</form>
			<div class="span9" style="width: 74%; margin-top: -26px">
				<div class="table-responsive">
						<table class="table  table-striped content_rwgl" id="demandlist">
							<thead>
								<tr>
									<th>序号</th>
									<th>指标名称</th>
									<th>指标编码</th>
									<!-- <th>所在大洲</th>
									<th>所在经济区</th> -->
									<th>操作</th>
								</tr>
								</thead>
							<tbody id="tbody">
							<c:if test="${not empty zhibiao}">
								<c:forEach var="zhibiao" items="${zhibiao}" varStatus="ts">
									<tr>
										<td>${ts.index+1 }</td>
										<td>${zhibiao.menu_name}</td>
										<td>${zhibiao.menu_id}</td>
										
										<%-- <td>${country.continent}</td>
										<td>${country.economicZone}</td> --%>
										<td><a class="renwu_select" style="text-decoration: none"
											href="#" data-toggle="modal" id="add_0"
											data-target="#editDemand"
											onclick="editDemand1('${zhibiao.menu_id }','${zhibiao.menu_name }')">修改</a>
											<a class="renwu_select" class="renwu_select"
											style="cursor: pointer"
											onclick="deldemand('${zhibiao.menu_id }')">删除</a></td>
									</tr>
								</c:forEach>
							</c:if>
						</tbody>
							</table>
							<script type="text/javascript">
							var demo ;
							 $(document).ready(function(){
									demo = $("#form").Validform({
										tiptype:2,
										showAllError:true
									});
							  });
							 function initStatus(statuss) {
									$("#select1>dd").removeClass("active");
									$("#s"+statuss).attr("class","active");
								}
							function editDemand1(menu_id,menu_name)
							 {
								
								 $("#myModalLabel").text("修改");
								 $("#button").text("确认修改");
								 $("#menu_id").attr("value",menu_id);
								 $("#menu_name").attr("value",menu_name);
								/*  $("#continent").attr("value",continent);
								 $("#economicZone").attr("value",economicZone); */
								 $("#button").attr("onclick","modify()");
							 }
							 function OpenAddModel(){
								 $("#myModalLabel").text("指标字典添加");
								 $("#menu_name").attr("value","");
						/* 		 $("#continent").attr("value","");
								 $("#economicZone").attr("value",""); */
								 $("#button").text("添加");
								 $("#button").attr("onclick","addCountry()");
								}
							 function modify(){
									var url = "<%=path%>/ZhibiaoDict/updatezhibiao";
									var data1 = $("#form").serialize();
									$.post(url,data1,function(data){
										
										if(data=="1")
										{
											alert("修改成功");
											window.location.href="<%=path%>/ZhibiaoDict/zhibiaoDict";
										}else
										{
											alert("任务失败！");
										}
									});
								 }
							 function addCountry(){
								 var text=document.getElementById("menu_name").value;//通过id获取需要验证的表单元素的值
								
								   if(text=="" ){//当上面获取的值为空时
								     alert("不能为空哦！");//弹出提示
								     return false;//返回false（不提交表单）
								   }
								   else{
								 var status = demo.check(false);
									if(status==true){
										 var url = "<%=path %>/ZhibiaoDict/addzhibiao";
										 var data1 = $("#form").serialize();
											$.post(url,data1,function(data){
												
												if(data==1){
													alert('增加成功！');
													window.location.href="<%=path %>/ZhibiaoDict/zhibiaoDict"; 
												}else {
													alert('增加失败！');
												}
											});
									}
							 }
							 }
							 function deldemand(id){
								 if(confirm("确定删除选中项目吗？")){
										var url = "<%=path %>/ZhibiaoDict/deletezhibiao?id="+id;
										$.post(url,function(data){
											if(data=="1"){
												alert("删除成功！");
											}else{
												alert("删除失败！");
											}
											window.location.href="<%=path %>/ZhibiaoDict/zhibiaoDict"; 
										},"text");
									 }
							 };
							</script>
					
					<div class="listtablebot">${page.pageStr }</div>
					</div>
				</div>
			</div>
		</div>
    <!-- Modal -->
<div class="modal fade" id="editDemand" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">指标添加</h4>
      </div>
      <form id="form" method="POST">
     
      <input type="hidden" name="menu_id" id="menu_id">
       <!--  <a>大洲</a>  
          <select name='continent' id="continent" >  
      <option value ="亚洲">亚洲</option>  
      <option value ="欧洲">欧洲</option>  
      <option value="澳洲">澳洲</option>  
      <option value="非洲">非洲</option>
      <option value="北美洲">北美洲</option>  
      <option value="南美洲">南美洲</option>   
    </select>
      <a>经济区</a>  
          <select name='economicZone' id="economicZone">  
      <option value ="欧洲联盟">欧洲联盟</option>  
      <option value ="北美自由贸易区">北美自由贸易区</option>  
      <option value="亚太经济合作组织">亚太经济合作组织</option>   
    </select> -->
      <div class="modal-body">
        	<div class="form-group">
				<label for="exampleInputEmail1">指标名称</label> <input type="text"
					class="form-control content_zjnrcqtext" name='menu_name' id="menu_name" value="" placeholder="指标名称" datatype="s" nullmsg="请输入指标名称！" errormsg="指标名称为英文或者汉字！">
			</div>
      </div>
      </form>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关 闭</button>
        <button type="button" class="btn btn-primary" id="button" onclick="addCountry()">确认添加</button>
      </div>
    </div>
  </div>
</div>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    </body>
</html>
